/**
 * Copyright (c) Glodon Co. Ltd.
 */
package com.cws.service;


import java.util.List;
import java.util.Map;

import javax.annotation.Resource;



import org.springframework.beans.factory.annotation.Autowired;

import com.cws.dao.IBaseDAO;
import com.cws.model.Page;

/**
 * Business 和 Service 接口实现类的基础父类
 * <p>
 * <b>创建日期</b> 2011年12月6日
 * </p>
 * @author lysming
 * @since 3.0.1-SNAPSHOT
 */
public class BaseService implements IBaseService {
    
    /** 进行数据库对象访问操作的对象 */
    @Autowired
    protected IBaseDAO baseDAO;

    @Override
    public IBaseDAO getBaseDAO() {
        return this.baseDAO;
    }

    @Override
    public boolean save(Object po) {
        getBaseDAO().save(po);
        return true;
    }

    @Override
    public boolean update(Object po) {
        getBaseDAO().update(po);
        return true;
    }

    @Override
    public boolean delete(Object po) {
        getBaseDAO().delete(po);
        return true;
    }

    @Override
    public <T> T get(Class<T> poClass, String id) {
        return (T) getBaseDAO().get(poClass, id);
    }

    @SuppressWarnings("deprecation")
    @Override
    public Page<?> getAsPage(String[][] params) {
        return getBaseDAO().getPage(params);
    }

    @Override
    public Page<?> getAsPage(Map<String, ?> params) {
        return getBaseDAO().getPage2(params);
    }

    @Override
    public <T> Page<T> getAsPage2(Map<String, ?> queryParams) {
        return getBaseDAO().getPage2(queryParams);
    }
    
    @SuppressWarnings("deprecation")
    @Override
    public List<?> query(String[][] params) {
        return getBaseDAO().queryList(params);
    }
    
    @Override
    public List<?> query(Map<String, ?> params) {
        return getBaseDAO().queryList2(params);
    }


    @Override
    public <T> List<T> query2(Map<String, ?> queryParams) {
        return getBaseDAO().queryList2(queryParams);
    }
    
    @Override
    public Long getCount(Class<?> clazz, String field) {
        return getBaseDAO().getCount(clazz, field);
    }

    @Override
    public Long getCount(Map<String, Object> queryParams) {
        return getBaseDAO().getCount(queryParams);
    }

    @Override
    public long getCount(String hql, Map<String, Object> params) {
        return getBaseDAO().getCount(hql, params);
    }

    @Override
    public long getCountBySql(String sql, Map<String, ?> params) {
        return getBaseDAO().getCountBySql(sql, params);
    }
    

}